
##
## MODELS - DETERMINANTS OF LIVING STANDARDS ----------------------------------- 
##

rm(list=ls())

###
### PACKAGES -----------------------------------------------------
### 

library(tidyverse)
library(fixest)

## SET WORKING DIRECTORY -------------------------------------------------

#> set working directory to p drive here

#setwd("P:/just")

##
## LOADING DATA ----------------------------------------------------------
##

load(file="Complete DLS data file_household level.RData")


##
## SIMPLE MODELS ---------------------------------------------------------------
## 

m1 <- feols(dls_min7 ~ hhsize,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)

summary(m1)

m2 <- feols(dls_min7 ~ highestdegree_secondary,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m2)

m3 <- feols(dls_min7 ~ occupation_agriculture_dum,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m3)

m4 <- feols(dls_min7 ~ rural,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m4)

m5 <- feols(dls_min7 ~ hhhead_absent,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m5)

m6 <- feols(dls_min7 ~ hhhead_female,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m6)

m7 <- feols(dls_min7 ~ female_only,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m7)


m8 <- feols(dls_min7 ~ dependents_children_dum ,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m8)


m9 <- feols(dls_min7 ~ hhsize+highestdegree_secondary+occupation_agriculture_dum+rural+hhhead_absent+hhhead_female+female_only+dependents_children_dum,
            fixef = c("region_num_raw", "survey_year"),
            data=dls)
summary(m9)


models <- etable(m1,m2,m3,m4, m5, m6, m7,  m8, m9)
models


models <- etable(m1,m2,m3,m4, m5, m6, m7, m8, m9,  coefstat = "confint", signif.code=NA)
models

write.csv(models, file = "supplementary table s5.csv")

